package com.demo.boot.bean;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @author zhengqiang
 * @description 权限实体
 * 2016-10-28
 */
@Entity
@Table(name="PERMISSION")
public class Permission {
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private long id;
	
	private String code;//权限指令
	
	private String text;//权限名称
	
	private String action;//视图名称或者路径
	
	private String iconCls;//菜单图标
	
	private int position;//排序
	
	@ManyToOne
	private Permission parent;//上级权限

	@Transient
	private List<Permission> children = new ArrayList<Permission>();
	
	@Transient
	public boolean getLeaf(){//是否为子叶目录
		if(this.children==null||this.children.size()==0){
			return true;
		}
		return false;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	public Permission getParent() {
		return parent;
	}

	public void setParent(Permission parent) {
		this.parent = parent;
	}

	public List<Permission> getChildren() {
		return children;
	}

	public void setChildren(List<Permission> children) {
		this.children = children;
	}
	
	
}
